package leetcode;

/**
 * Created by Ghost on 2014/12/6.
 */
public class Container_With_Most_Water {
    public int maxArea(int[] height) {
        if(height==null || height.length==0)
            return 0;
        int left = 0;
        int right = height.length-1;
        int max = 0;
        while(left<right){
            int area = (right-left)*Math.min(height[left],height[right]);
            max = max<area?area:max;
            if(height[left]<height[right])
                left++;
            else
                right--;
        }
        return max;
    }

    public static void main(String[] args){
        Container_With_Most_Water container_with_most_water = new Container_With_Most_Water();
        int[] height = {2};
        System.out.println(container_with_most_water.maxArea(height));
    }

}
